Some bug fixes. Refactoring to ui-sref.