Added external API,
fixed bugs
ready for testing