Fixed critical errors in most files

Note to self: use -Wall flag