Lua Code:
create_cast_bar = function(self, unit, frame)
...
frame.Castbar = Castbar
end
Is "frame" the unit frame here? The castbar element only functions when "Castbar" is a child of that object.
I'm going to guess that you'd want this to be "self.Castbar = Castbar" instead.