Divided code to multiple files
Tests almost done.
Must be working, haven't checked yet.
IO changes.