Some smaller misc fixes

Includes:
- remove unused variable
- prefer prefix ++operator for iterators
- add some error handling