rewrite of static analyzer, unfinished but runnable