Merge physics engine with refactor code