Const pointer and indexer fixes

See commits - i've tried to add tests for each case. Hope they're better this time.