Updated depracated ``has_key``. Fixed imports.