Fixed habitat calc function.