Fixed serious bugs