Added an environment parser.

Cleaned up some memory leaks.

Made lc_process()  cleanup, so calling lc_process() twice will do nothing.