Fixing some bugs

@kimoktm