Minor tweaks, optimizations and cleanup