added proper transitions
added idle connection detection; changed some names