Added headers to files, cleaned up code