Documented and cleaned some code. Also splitted some code up into multiple files.