Fix runtime bugs. But still have problems