Basic algorithm is working for P,Y for vapor - more checking needed, but basically works

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>