turned defaults into configurable options
added optional callback for state changes