reformatted code
added some interfaces for extensions
fixed npe