Fix some problems in new code