Made some minor performance improvements and bug fixes.