Fix misc bugs

Close #27
Close #26
Close #25