Added read write functions.

And modified input handling.