Initial support for new cost calc and minor fixes