slight fixes to horrible code