changes for better testing and documentation

Make classes and functions accessible on window object.
Rename externally accessed functions to start with capital letter.
Initial logic to recreate a selection automatically.