replaces fmin with std::min as per abma's request
bringing in changes from develop
fixed the calculations of tile byte offsets..