Refactor terrain generation and chunk handling

Fixes #35