Further code cleanup, experimenting with optimizations, things still work