Fixes several errors