Code cleared up a bit, defines moved up. solved ticket #5