Fixed crapload of bugs