Fixes and minor code tweaks.