Fix compilation, fix some errant bugs noted by JKC and reported/fixed (much thanks) - first attempt at 64 bit Max 6.1 compatibility, fixes for warnings.