[FIX] cli/server: fixes #1307, add missing Environment management blocks
[FIX] loading modules: load custom models earlier so that they are available when setting up models