First draft of normalization. Fixed some warnings and errors. TA wasn't sure about shadow variables.