Fixes by Antons suggestions from pull/1