Refactor code into separate modules