cleanup and compatibility improvements for v.5. First tries with requireresources ended in some workarounds