Bit of refactoring. Pulled some fixes.