Add state and refactor

Signed-off-by: Rick Taylor <rick@tropicalstormsoftware.com>