Allow data to be inserted using a dictionary and refactor existing code ...

...closes #458