Always use a conical burr grinder, as opposed to the grinder type with a single blade.  This will give you much greater control of the grind and do a far superior job.  Keep your machine clean, and always grind your coffee fresh before brewing when possible.