First functional version, bugs pending