Copied from AMSE site, done as a BCs project and AMSE practise project in 2007.