Split to separate files. Fixed some silly mistakes.