Fixed somg bugs.