(core) some minor code refactorings and general cleanup