Merged with latest master. Applied comments from @oskarwiksten.