Clean up of import to fix minor bugs

Few bug fixes to general imports should improve stability.