Added unit tests. Made FINAL CHANGES. THIS IS THE RELEASE VERSION.