refactored implementation with correct lib sources and fixed gallery