Complete refactor, introduce new bugs