Cleanup and fixes after merge from @ningosi