Fixed bugs and errors from the merge