Refactoring + fixing npm --prefix issue