Resource refactor + other fixes.