refactor some backend code, physics tweaks