Refactored some resource handling code
Further refactored resource handling
Set up default matrices
Added more logging
Fixed null ref exception (woops :P)