Added local variable support, moved internal commands to internals.c, added some cleanup function to free memory allocated elsewhere before exiting.