Fixed some bugs with ASSERTS in the Debug mode.