Big refactor based on feedback