[fixed] Several bugs preventing normal operation