Fixes, code cleanup