fixed all compilation errors. trying to fix seg fault in dispatch now