A few bug fixes. Added selling functionality (modified version of purchasing function).