Deleted unused code, refactor