fix bugs + cosmetic for #16