fix hover bug, some code cleanup