Some implicit/explicit variable declarations
better memory allocation
Refactored errors to GIO errors