Made some bug fixes.