Removed an unnecessary branch and added some asserts.