All remaining bugs seem to be numbers getting too extreme. Removing debug mode will make it run fine.
There still seems to be one problem: when you pass through the portal, the rotation is reversed. The space being oriented shouldn't cause that.
Fixed that last bug.