attachment function almost complete +various bug fixes +cleanups(remember to hold down arrow key while testing this)