Fixed many small bugs.