fixed linkout bug and cleaned up old code