Made decomposition routines more robust