added orientation checking block
fixed chunks not being saved on program termination