moved init constructor to act on instance of ts object instead of global state
temp commented out because it errors
updated to work with state objects instead of lib-globals