Updated subscribe API and added state change handlers.
0.4.0