Refactoring + cleanup