Extensively cleaned up debug output and added _CRT_SECURE_NO_WARNINGS