Small fixes

Small fixes and code cleanup