REFACTORING + BUG FIXES