large refactor of unused code