Massive refactor and rebase of gelatojs framework