Update happy.py

Bug fixes and performance improve for hgraph.