Fixes and code cleaning