Some refactoring, markup cleanup