added more helper functions, cleaned up matrix sub-selection logic / code, fixed bug in matrix sub-selection