Added an init method to State which is called when the State is registered. Fixes #2