Add basic state mechanism to client

Also, reorganize some code and imports to help with OCD.