Sources organization, various bug fixes