Fixed two bugs from bug report