Clean up of syso prints
Used Math.min and Math.max instead of ifs in some places for clarity.