Fix chunking on movement and improved the algorithm for chunk-generation.