refactor old code, remove unused stuff