Fixed some bugs and inconsistencies.