Refactor terrain generation and chunk handling

Fixes #35
merge #35
fixed gcc warnings