several small bugs

@javruben