Removed some functions no longer used, added a few code comments, changed the file structure.