  We study dynamics of bars in models of disk galaxies embeded in realistic
dark matter halos. We find that disk thickness plays an important, if not
dominant, role in the evolution and structure of the bars. We also make
extensive numerical tests of different N-body codes used to study bar dynamics.
Models with thick disks typically used in this type of modeling
(height-to-length ratio hz/Rd=0.2) produce slowly rotating, and very long,
bars. In contrast, more realistic thin disks with the same parameters as in our
Galaxy (hz/Rd= 0.1) produce bars with normal length Rbar approx R_d, which
rotate quickly with the ratio of the corotation radius to the bar radius
1.2-1.4 compatible with observations. Bars in these models do not show a
tendency to slow down, and may lose as little as 2-3 percent of their angular
momentum due to dynamical friction with the dark matter over cosmological time.
We attribute the differences between the models to a combined effect of high
phase-space density and smaller Jeans mass in the thin disk models, which
result in the formation of a dense central bulge. Special attention is paid to
numerical effects such as the accuracy of orbital integration, force and mass
resolution. Using three N-body codes -- Gadget, ART, and Pkdgrav -- we find
that numerical effects are very important and, if not carefully treated, may
produce incorrect and misleading results. Once the simulations are performed
with sufficiently small time-steps and with adequate force and mass resolution,
all the codes produce nearly the same results: we do not find any systematic
deviations between the results obtained with TREE codes (Gadget and Pkdgrav)
and with the Adaptive-Mesh-Refinement (ART) code.
