Code cleanup, fixed bug with generating uneven chunks.