Rewrite liquid flow, fixed bugs