forgot include statements, fixed other small bugs