Adding selection support

The multiple commits are caused by me uploading code via Github. I will rebase it all before I merge. 
I still have mixed feelings about the mixed markup structure. But we can change that at a later point in time.