Bug fixes, tests completion