added shape state, minor refactoring