fixed some low level bugs.