Ported core functionality to backbone + refactoring