Slight restructure and (untested!) plugin support