Moved defines into .h files, made some code right