Added maven building. Fixed minor bugs.