Various fixes to the core.

Signed-off-by: Chris Sanders <zidane@outlook.com>