Major commit, separated logic into multiple files.