refactor some code and make less buildable