Further comments added, command line options working, and memory handling added