addressing multiple windows issues

  * #490 - use unique_ptr and roll our own swap
  * #491 - use C++11 random uniform distribution on the range of indices