More special cases fixes and code cleaening.