Ported part of the fw bw analysis from java. Still  not done