Fixed misc bugs from refactor