Refactoring and cleanup

- Updated Buffer and Texture error handling.
- Work-in-progress, won't compile.