Import bugs develop

Changes from #700 cherry-picked onto develop