added key event support
fixed selection
added misc function for exception throwing
refactoring