First complete, tested version