Normalized line endings, fixed sortButtons to work with children elements, and some minor code cleanup