Patched various bugs