Cleaned up code, fixed bugs, etc.