fix some bugs to make stuff more explicitly bound

@cos please review