Several improvements and fixes on the core.