bug fixes to swing algorithm