intermediate state weight handling, new graph handling and some bug
fixes/optimizations