Changed the entire structure.

Added api methods.