Big refactor for better organizing source modules