Cleaned up code, still comments needed