Cleaned up the code a bit from comments and multiple definitions.