refactored modules into individual files

please merge this first, as rebasing further PRs could be tedious