Borrowed things from milkdrop.