fix bugs on develop and build mode (with help from @tcelestino)