Separate out functions from main part of JS code
Use I/O abstraction class for host communication