cleanup and reformatting, also broken hitdetection - needs fixing