cleaned up magic numbers, fixed most problems with Linux compatability