Fixed subselection mechanism.
Added basic error handling (just simple cases).