fix huge number of bugs.