Added the decompose function and minor edits..