reference before defined fix and https [MJ-858]