Added open class and Fixed heap bugs