added rough API sketch and some fooling with templates