Fixed a bug with details and trees positions.

Also sparated a few methods in their own file (cf MrNothingMath.cs