Cleaned up files and simplified the code a bit.