Simplifying core code + various other minor improvements

Fixes #286