more const correctness

+ formatting
+ use c++11 shrink_to_fit instead of stl swap trick