Cleaned up core, added logging and helpers