Misc bug fixes and optimizations, frontend tweaks