Fixed errors, changed types, removed unused variables