Updated code

Also cleaned up and deleted unnecessary files.