Lotsa small changes. Moved input handling into selection.js