Fixed bunch of bugs.