Bugfixing and code format