Clean up switch state functions
Replace object extend function with one from http://stackoverflow.com/questions/12317003/something-like-jquery-extend-but-standalone