Restructured stuff. First attempt to use own resource implementation, but not fully working.