Added a function to base58 encode; removed duplicate code.